package com.english_test_sys.service.Impl;

import com.english_test_sys.mapper.WordMapper;
import com.english_test_sys.pojo.Category;
import com.english_test_sys.pojo.UserWordRecord;
import com.english_test_sys.pojo.Word;
import com.english_test_sys.service.WordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class WordServiceImpl implements WordService {

    @Autowired
    private WordMapper wordMapper;
    @Override
    public List<Category> getAllCategories() {
        return wordMapper.selectAllCategories();
    }

    @Override
    public List<Word> getWordsByCategory(Integer categoryId) {
        //获取分类下单词
        return wordMapper.selectWordsByCategory(categoryId);

    }
    @Override
    public UserWordRecord findByUserIdAndWordId(Integer userId, Integer wordId) {
        return wordMapper.findByUserIdAndWordId(userId, wordId);
    }

    @Override
    public void save(UserWordRecord record) {
        wordMapper.insert(record);
    }

    @Override
    public void update(UserWordRecord record) {
        wordMapper.update(record);
    }
    @Override
    public List<Word> getMistakeWordsByUserId(Integer userId) {
        return wordMapper.selectMistakeWordsByUserId(userId);
    }
}